package com.briup.jz.web.controller;


import com.briup.jz.bean.OrderLine;
import com.briup.jz.service.IOrderLineService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(description="订单项分类相关接口")
@RestController
@RequestMapping("/OrderLine")
public class OrderLineController {

	
    @Autowired
    private IOrderLineService iOrderLineService;
    
    @ApiOperation(value = "保存或更新所有订单项分类")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id",value = "编号",paramType = "form"),
        @ApiImplicitParam(name="number",value = "数量",paramType = "form"),
        @ApiImplicitParam(name="price",value = "单价",paramType = "form"),
        @ApiImplicitParam(name="productId",value = "产品编号",paramType = "form"),
        @ApiImplicitParam(name="orderId",value = "订单编号",paramType = "form"),
       
        
})
    @PostMapping("saveorupdate")
    public Message saveorudate(OrderLine orderLine){
        iOrderLineService.saveOrUpdate(orderLine);
        return MessageUtil.success("操作成功");
    }

    @ApiOperation(value = "查询所有订单项分类")
    @GetMapping("query")
    public  Message query(Long id,Long proid,Long orderid){
        List<OrderLine> orderLines = iOrderLineService.query(id,proid,orderid);
        return  MessageUtil.success(orderLines);
    }
    
    @ApiOperation(value = "根据id删除资讯分类")
    @GetMapping("delete")
    public Message delete(Long id){
        iOrderLineService.deleteById(id);
        return MessageUtil.success("操作成功");
    }
}
